package com.cw.jeeyt.service.converter.process;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.process.ProcessLeaveBo;
import com.cw.jeeyt.dao.model.process.ProcessLeaveDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 请假流程转换类
 *
 * @author chenw
 * @date 2019-03-10 20:55:56
 */
public class ProcessLeaveConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static ProcessLeaveBo do2Bo(ProcessLeaveDo model) {
        if (model == null) {
            return null;
        }
        ProcessLeaveBo bo = new ProcessLeaveBo();
        bo.setId(model.getId());
        bo.setProcInsId(model.getProcInsId());
        bo.setStartTime(model.getStartTime());
        bo.setEndTime(model.getEndTime());
        bo.setLeaveType(model.getLeaveType());
        bo.setReason(model.getReason());
        bo.setDeptLeadText(model.getDeptLeadText());
        bo.setHrText(model.getHrText());
        bo.setApplyTime(model.getApplyTime());
        bo.setCreateBy(model.getCreateBy());
        bo.setCreateDate(model.getCreateDate());
        bo.setUpdateBy(model.getUpdateBy());
        bo.setUpdateDate(model.getUpdateDate());
        bo.setRemarks(model.getRemarks());
        bo.setDelFlag(model.getDelFlag());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static ProcessLeaveDo bo2Do(ProcessLeaveBo bo) {
        if (bo == null) {
            return null;
        }
        ProcessLeaveDo model = new ProcessLeaveDo();
        model.setId(bo.getId());
        model.setProcInsId(bo.getProcInsId());
        model.setStartTime(bo.getStartTime());
        model.setEndTime(bo.getEndTime());
        model.setLeaveType(bo.getLeaveType());
        model.setReason(bo.getReason());
        model.setDeptLeadText(bo.getDeptLeadText());
        model.setHrText(bo.getHrText());
        model.setApplyTime(bo.getApplyTime());
        model.setCreateBy(bo.getCreateBy());
        model.setCreateDate(bo.getCreateDate());
        model.setUpdateBy(bo.getUpdateBy());
        model.setUpdateDate(bo.getUpdateDate());
        model.setRemarks(bo.getRemarks());
        model.setDelFlag(bo.getDelFlag());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<ProcessLeaveBo> doList2BoList(List<ProcessLeaveDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), ProcessLeaveConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<ProcessLeaveDo> boList2DoList(List<ProcessLeaveBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), ProcessLeaveConverter::bo2Do));
    }
}